#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
using namespace std;

/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
struct TreeNode {
        int val;
        TreeNode *left;
        TreeNode *right;
        TreeNode(int x) : val(x), left(NULL), right(NULL) {}
    };
class Codec {
public:
    // Encodes a tree to a single string.
    string serialize(TreeNode* root) {
        queue<TreeNode*> buffer;
        string ans;
        buffer.push(root);
        while (!buffer.empty()){
            TreeNode* temp = buffer.front();
            buffer.pop();
            if(temp){
                ans+=to_string(temp->val);
                ans+=",";
                buffer.push(temp->left);
                buffer.push(temp->right);
            } else{
                ans+="null,";
            }
        }
        return ans;
    }

    // Decodes your encoded data to tree.
    TreeNode* deserialize(string data) {
        int n = data.size();
        int temp = 0;
        if(n<=1) return nullptr;
        queue<TreeNode*> node;

        for (int i = 0; i < n; ++i) {
            if(data[i]!=','){
                if(data[i]!='n'){
                    temp+= temp*10+data[i]-'0';
                } else{
                    temp = 0;
                    i+=3;
                }
            } else{
                if(temp!=0){
                    TreeNode* added_node = new TreeNode(temp);
                    node.push(added_node);
                } else{
                    TreeNode* null_data = nullptr;
                    node.push(null_data);
                }
            }
        }
        while (!node.empty()){

        }


    }
};

int main(){
}